package cn.jhc.teachingquality.net.practice;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;

import org.jsoup.nodes.Document;

import java.util.HashMap;
import java.util.Map;

import cn.jhc.teachingquality.Global;
import cn.jhc.teachingquality.bean.PracticeDetail;
import cn.jhc.teachingquality.bean.PracticeLog;
import cn.jhc.teachingquality.net.TeachingQualityRequest;

/**
 * Created by luyanfei on 16-3-18.
 */
public class SavePracticeLogRequest extends TeachingQualityRequest<String> {
    private static final String SAVE_PRACTICE_URL = Global.URL_PREFIX + "/dgSxrzAction!save.shtml";

    private PracticeLog practiceLog;
    private PracticeDetail practiceDetail;

    public SavePracticeLogRequest(PracticeLog practiceLog, PracticeDetail practiceDetail,
                                  Response.Listener<String> listener) {
        super(Method.POST, SAVE_PRACTICE_URL, listener);
        this.practiceLog = practiceLog;
        this.practiceDetail = practiceDetail;
    }

    @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        Map<String, String> map = new HashMap<>();
        map.put("id", practiceLog.getHiddenId());
        map.put("dgSxrz.id", practiceLog.getHiddenId());
        map.put("dgSxrz.dgSxqk.id", practiceDetail.getDetailHiddenId());
        map.put("dgSxrz.jsYj", practiceDetail.getRemark());
        return map;
    }

    @Override
    protected String handleResponse(Document document) {
        return "保存成功";
    }
}
